//
//  LoginFunctions.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/11.
//

import Foundation

enum LoginType:String , CaseIterable, Identifiable {
    var id: String {
          self.rawValue
      }
    case WX = "wx"
    case QQ = "qq"
    case PHONE = "phone"// 电话
    case APPLE = "apple"// 苹果
    case TOURIST = "tourist"// 游客
}

private var wxDelegate: LoginProtocol? = nil
private var qqDelegate: LoginProtocol? = nil
private var appleDelegate: LoginProtocol? = nil
private var touristDelegate: LoginProtocol? = nil

func getLogin(type: LoginType)-> LoginProtocol? {
    switch type {
    case .WX:
        if wxDelegate == nil {
            wxDelegate = LoginDelegate(login:WxLogin())
        }
        return wxDelegate
    case .QQ:
        if qqDelegate == nil {
            qqDelegate = LoginDelegate(login:QQLogin())
        }
        return qqDelegate
    case .APPLE:
        if appleDelegate == nil {
            appleDelegate = LoginDelegate(login:AppleLogin())
        }
        return appleDelegate
    case .TOURIST:
        if touristDelegate == nil {
            touristDelegate = LoginDelegate(login:TouristLogin())
        }
        return touristDelegate
    case .PHONE:
        return nil
    }
}
